<template>
    <div>

        <el-dialog
            v-model="toRoleVisible"
            :destroy-on-close="true"
            :close-on-click-modal="false"
            title="分配角色"
            @open="handleOpen"
            @close="handleClose"
        >
            <el-transfer v-model="assignRoles" :data="allRoles" :titles="['未分配', '已分配']" />
            <template #footer>
                <span class="dialog-footer">
                    <el-button @click="toRoleVisible = false"
                        >取消</el-button
                    >
                    <el-button type="primary" @click="handleOK">
                        确定
                    </el-button>
                </span>
            </template>
        </el-dialog>
    </div>
</template>
<script setup>
import { ElMessage } from "element-plus";
import { defineEmits, ref } from "vue";
import { Plus } from '@element-plus/icons-vue'
import { storeToRefs } from "pinia";
import { useUserStore } from "../../../stores/user";
import { assignUserRole } from "../../../services/user";
const userStore = useUserStore();
const {userId,toRoleVisible,allRoles,assignRoles} = storeToRefs(userStore);
const formLabelWidth = ref(100);

const handleClose = () => {};
const handleOK = async () => {
    await assignUserRole(userId.value,assignRoles.value);
    toRoleVisible.value = false;
};
</script>
<style scoped>
.add-btn {
    display: flex;
    justify-content: flex-end;
}
</style>
